"""
@name : practice
@author : wangshenghu
@projectname: tlbb
@Date  : 2022/7/13
"""
from functools import reduce
# 练习1
# 使用reduce取出lst里的数字，实现12349
lst = ['a', '1', '2bb', '234', '', '9']
lst1 = []
for i in lst:
    for j in i:
        if j.isdigit():
            lst1.append(int(j))


def func1(x, y):
    return x * 10 + y


print(reduce(func1, lst1))

# 练习2
# 有以下列表：list1=[7, -8, 5, 4, 0, -2, -5] 正数在前负数在后 整数从小到大 负数从大到小
lst1 = [7, -8, 5, 4, 0, -2, -5]
lst2 = filter(lambda x: x < 0, lst1)
lst3 = filter(lambda x: x >= 0, lst1)
lst4 = sorted(lst3) + sorted(lst2, reverse=True)
print(lst4)


# 练习3
s = 'asdf234GDSdsf23'
s2 = "".join(sorted(s, key=lambda x: (x.isdigit(), x.isdigit() and int(x) % 2 == 0, x.isupper(), x)))
print(s2)
